﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WebPic.Sample.Comum;
using WebPic.Sample.Modelo;
using WebPic.Sample.Modelo.Entidades;
using WebPic.Sample.Modelo.Servicos.Interfaces;

namespace WebPic.Sample.Modelo.Servicos {


    public class ServiceCliente : IServiceCliente
    {
        private readonly IValidationDictionary _modelState;
        private readonly UnitOfWork _unitOfWork;
        public ServiceCliente(IValidationDictionary modelState, UnitOfWork unitOfWork)
        {
            _modelState = modelState;
            _unitOfWork = unitOfWork;
        }
        public bool Add(Cliente cliente)
        {
           _unitOfWork.Cliente.Add(cliente);
            return true;
        }

        public bool Update(Cliente cliente)
        {
           _unitOfWork.Cliente.Update(cliente);
            return true;

        }

        public bool Remove(Cliente cliente)
        {
          
            if(_modelState.IsValid)
                _unitOfWork.Cliente.Remove(cliente);
            return _modelState.IsValid;

        }
    }
}
